<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix" style="display:flex;">
        <p style="margin-top:10px;font-size:14px">一体杆名称：</p><el-input v-model="params.poleName" placeholder="请输入一体杆名称" style="width:300px; margin:0 10px" />
        <p style="margin-top:10px;font-size:14px">一体杆编号：</p><el-input v-model="params.poleNumber" placeholder="请输入一体杆编号" style="width:300px;margin:0 10px" />
        <p style="margin-top:10px;font-size:14px"> 处置状态</p><el-select v-model="params.handleStatus" placeholder="请选择处置状态" style="width:300px;margin:0 10px">
          <el-option label="全部" />
          <el-option label="未派单" :value="0" />
          <el-option label="已派单" :value="1" />
          <el-option label="已结单" :value="2" />
          <el-option label="已完成" :value="3" />
        </el-select>
        <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
      </div>

      <el-table :data="list">
        <el-table-column prop="" label="序号" width="80">
          <template #default="{$index}">
            {{ $index+1+5*(params.page-1) }}
          </template>
        </el-table-column>
        <el-table-column prop="poleName" label="一体杆名称" width="200" />
        <el-table-column prop="poleNumber" label="一体杆编号" width="200" />
        <el-table-column prop="errorType" label="故障类型" width="200" />
        <el-table-column prop="handleStatus" label="处置订单" width="200">
          <template #default="{row}">
            <span v-if="row.handleStatus===0">未派单</span>
            <span v-else-if="row.handleStatus===1">已派单</span>
            <span v-else-if="row.handleStatus===2">已接单</span>
            <span v-else-if="row.handleStatus===3">已完成</span>
          </template>
        </el-table-column>
        <el-table-column prop="warningTime" label="告警时间" />
        <el-table-column prop="" label="操作">
          <template #default="{row}">
            <el-button :disabled="row.handleStatus===1 || row.handleStatus===2||row.handleStatus===3" type="text">派单</el-button>
            <el-button type="text">详情</el-button>
            <el-button :disabled="row.handleStatus===1" type="text">删除</el-button>
          </template>

        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-row type="flex" justify="end">
        <el-pagination
          :page-size="params.pageSize"
          :current-page="params.page"
          layout="total, prev, pager, next,sizes"
          :total="total"
        />
      </el-row>
    </el-card>
  </div>
</template>

<script>
import { getListWarningAPI } from '@/api/warningRecord'
export default {
  data() {
    return {
      list: [],
      total: 10,
      params: {
        page: 1,
        pageSize: 5,
        poleName: '',
        poleNumber: '',
        handleStatus: ''
      }
    }
  },
  created() {
    this.onLoad()
  },
  methods: {
    // 点击查询
    onSubmit() {
      this.onLoad()
    },
    async onLoad() {
      const res = await getListWarningAPI(this.params)
      console.log(res)
      this.list = res.data.rows
      this.total = res.data.total
    }
  }
}
</script>

<style>

</style>
